package com.zoro.barn.business.service.pp.server.facade;

import com.zoro.barn.business.service.pp.server.BarnDocumentServerService;
import com.zoro.barn.dto.documentsql.document.DocumentQueryDto;
import org.springframework.stereotype.Component;

/**
 * @author zhaoxingwu
 */
@Component
public class BarnDocumentServerServiceFacade {
    private final BarnDocumentServerService barnDocumentServerService;

    public BarnDocumentServerServiceFacade(BarnDocumentServerService barnDocumentServerService) {
        this.barnDocumentServerService = barnDocumentServerService;
    }

   public int countByProduct(String productId){
       DocumentQueryDto dto = new DocumentQueryDto();
       dto.setProductId(productId);
       DocumentQueryDto resultDto = this.barnDocumentServerService.countByProduct(dto);
       if (resultDto == null || resultDto.getDocumentCount() == null) {
           return 0;
       }
       return resultDto.getDocumentCount();
   }

    public int countByProject(String projectId){
        DocumentQueryDto dto = new DocumentQueryDto();
        dto.setProjectId(projectId);
        DocumentQueryDto resultDto = this.barnDocumentServerService.countByProject(dto);
        if (resultDto == null || resultDto.getDocumentCount() == null) {
            return 0;
        }
        return resultDto.getDocumentCount();
    }

}
